﻿using Bridge.Shared.Models;
using Microsoft.AspNetCore.Mvc;
using OrderVouchers;
using OrderVouchers.Input;
using OrderVouchers.Output;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;

namespace Vouchers
{
    [Route("[controller]/[action]")]
    public class OrderVoucherController : AbpController
    {
        private IOrderVoucherService _orderService { get; set; }
        public OrderVoucherController(IOrderVoucherService orderService) {
        _orderService = orderService;
        
        }
        [HttpPost]
        public async Task<PageResponseResult<OrderVoucherOutput>> GetOrderList([FromBody] OrderVoucherInput input)
        {
            try
            {
              return  await _orderService.GetOrderList(input);
            }
            catch (Exception e)
            {

                return PageResponseResult<OrderVoucherOutput>.Fail("获取订单出错！");
            }
        }

        [HttpPost]
        public async Task<ResponseResult> CreateOrUpdateOrder([FromBody] CreateOrUpdateOrderVoucherInput input)
        {
            try
            {
                return await _orderService.CreateOrUpdateOrder(input);
            }
            catch (Exception e)
            {

                return PageResponseResult<OrderVoucherOutput>.Fail("保存订单出错！");
            }
        }
    }
}
